package com.aidong.util;

import java.util.List;

import com.pili.Hub;
import com.pili.PiliException;
import com.pili.Stream;
import com.pili.Stream.StreamList;
import com.qiniu.Credentials;

public class QiniuUtil {
	// 设置好账号的ACCESS_KEY和SECRET_KEY
	public static String ACCESS_KEY = "SOMBFhoOmUgnKcmLYPoYlZxUa4E7E5sJp7nW5YDU"; // 这两个登录七牛
	// 账号里面可以找到
	public static String SECRET_KEY = "be2JUix4G-CayPHwXa6Wz4TD9E13Ffjc6QQH9qzn";

	// 要上传的空间 正式
	//public static String BUCKET_NAME = "adong"; // 对应要上传到七牛上 你的那个路径（自己建文件夹
	//测试									// 注意设置公开）
	public static String BUCKET_NAME = "test"; // 对应要上传到七牛上 你的那个路径（自己建文件夹
	// 注意设置公开）

	//测试
	public static String QINIU_URL = "https://7xvyvy.com1.z0.glb.clouddn.com/";
	//正式
	//public static String QINIU_URL="http://o99vzhdmd.bkt.clouddn.com/";
	
	//测试视频地址
	public static String QINIU_VIDEO_URL="https://7xvyvy.com1.z0.glb.clouddn.com/";
	
	//正式视频地址
	//public static String QINIU_VIDEO_URL="http://ociezpyik.bkt.clouddn.com/";
	// 视频需要
	// 设置转码操作参数
	public String FOPS = "avthumb/mp4/s/640x360/vb/1.25m";
	// 设置转码的队列
	public String PIPELINE = "qiniu0629";
	
	//视频截图
	public String VIDEOPNG="?vframe/jpg/offset/2/w/640/h/640";
	
	//二维码正式
	public static String TOWPREIX = "https://m.aidong.me/share/member/";
	//测试
	//public static String TOWPREIX = "http://m1.aidong.me/share/member/";
	
	//直播
	private static String HUB_NAME="";
	private Credentials mCredentials = new Credentials(ACCESS_KEY, SECRET_KEY);
    private Hub mHub = new Hub(mCredentials, HUB_NAME);
    
   /* public void testListStreams() {
        try {
            System.out.println("mHub=" + mHub);
            StreamList streamList = mHub.listStreams();
            if (streamList != null) {
                assertNotNull(streamList.getMarker());
                assertNotNull(streamList.getStreams());
                for (Stream stream : streamList.getStreams()) {
                    assertNotNull(stream);
                }
            }
        } catch (PiliException e) {
            e.printStackTrace();
        }

        String[] markers = new String[]{null, "", " ", "  "};
        for (String marker : markers) {
            try {
                StreamList streamList = mHub.listStreams(marker, 0);
                if (streamList != null) {
                    assertNotNull(streamList.getMarker());
                    assertNotNull(streamList.getStreams());
                    for (Stream stream : streamList.getStreams()) {
                        assertNotNull(stream);
                    }
                }
            } catch (PiliException e) {
                e.printStackTrace();
            }
        }

        int[] limitCounts = new int[]{-1, 0, 1};
        for (int limitCount : limitCounts) {
            try {
                StreamList streamList = mHub.listStreams(null, limitCount);
                if (streamList != null) {
                    assertNotNull(streamList.getMarker());
                    assertNotNull(streamList.getStreams());
                    for (Stream stream : streamList.getStreams()) {
                        assertNotNull(stream);
                    }
                }
            } catch (PiliException e) {
                e.printStackTrace();
            }
        }

        try {
            final String title = "test_stream_list";
            mHub.createStream(title, null, null);
            boolean found = false;
            String marker = null;
            while (!found) {
                StreamList streamList = mHub.listStreams(marker, 300);
                marker = streamList.getMarker();
                List<Stream> list = streamList.getStreams();
                for (Stream stream : list) {
                    if (title.equals(stream.getTitle())) {
                        String res = stream.delete();
                        System.out.println("found stream:" + title + ",delete:" + res);
                        found = true;
                        return;
                    }
                }
            }
        } catch (PiliException e) {
            e.printStackTrace();
        }
    }*/
}
